using System;
using System.Collections.Generic;
using ACS.Compiler.Tables;
using ACS.Compiler.Tables.Modes;
using ACS.Compiler.Tree;
using antlr;

namespace ACS.Compiler.Util
{
    public class ErrorsTrace
    {
        private List<string> _errors;
        public List<string> Errors
        {
            get
            {
                return _errors;
            }
        }

        bool HasErrors
        {
            get
            {
                return _errors == null || _errors.Count == 0; 
            }
        }

        public void AddError(string error, IToken t)
        {
            string prefix = "";
            if (t != null)
            {
                prefix = String.Format("Error in file:{0}, line:{1} position:{2}.", t.getFilename(), t.getLine(), t.getColumn());
            }
            _errors.Add(prefix + error);
        }

        public ErrorsTrace()
        {
            _errors = new List<string>();
        }


    }
}
